package mock.servicesdirectory.contacts.dao.daoimpl;

import java.util.List;

import mock.servicesdirectory.common.entities.Contact;
import mock.servicesdirectory.common.entities.Users;
import mock.servicesdirectory.contacts.dao.daointerface.UserDao;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class UserDaoImpl extends HibernateDaoSupport implements UserDao{
	
	/**
	 * Method used to get user infomation that corresponse with userId
	 */
	@Override
	public Users getUser(int userId){
		String sql = "from Users as u where u.userId=:userId";		
		Session session = this.getSession();
		Query query = session.createQuery(sql);
		query.setInteger("userId", userId);

		@SuppressWarnings("unchecked")
		List<Users> users = query.list();
		if (users == null || users.size() == 0) {
			return null;
		} else {
			return users.get(0);
		}
	}

	@Override
	public List<Users> getUsers() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getPassword(String userName) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getEmail(String userName) {
		// TODO Auto-generated method stub
		return null;
	}
}
